
package com.idealighter.game.games.sirenniuniu.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.games.sirenniuniu.message.ReqCallDealerMsg;
import com.idealighter.game.message.ModuleMsgIdConstant;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;
import com.idealighter.utils.code.RandCodeUtil;

import java.util.concurrent.TimeUnit;


@ResMsgHandler(ModuleMsgIdConstant.SiRenNiuNiu.RES_READY_OVER)
public class ResReadyOverHandler implements ResMessageHandler {

  // private static final Logger LOG = LoggerFactory.getLogger(ResReadyOverHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    // ResReadyOverMsg msg = (ResReadyOverMsg)message;
    // 随机1到3秒叫庄
    player.schedule(() -> callDealer(player, RandCodeUtil.randomBoolean()),
        RandCodeUtil.random(1, 3), TimeUnit.SECONDS);
  }

  /**
   * 叫庄.
   * 
   * @param player .
   * @param call .
   */
  public void callDealer(Player player, boolean call) {
    ReqCallDealerMsg msg = new ReqCallDealerMsg();
    msg.setCall((byte) (call ? 1 : 0));
    player.sendMsg(msg);
  }
}
